import request from '@/utils/request';

export async function getProductBomOverviewByPage(params: any) {
  return request('/api/design/getProductBomOverviewByPage', {
    method: 'POST',
    data: params,
  });
}

export async function getProductBomOverviewAndReviewByPage(params: any) {
  return request('/api/design/getProductBomOverviewAndReviewByPage', {
    method: 'POST',
    data: params,
  });
}

export async function getProductBomOverviewByBatchProductId(params: any) {
  return request('/api/design/getProductBomOverviewByBatchProductId', {
    method: 'POST',
    data: params,
  });
}

// 新增bom
export async function addProductBomOverview(params: any) {
  return request('/api/design/addProductBomOverview', {
    method: 'POST',
    data: params,
  });
}

export async function updateProductBomOverview(params: any) {
  return request('/api/design/updateProductBomOverview', {
    method: 'POST',
    data: params,
  });
}

export async function delProductBomOverview(params: any) {
  return request('/api/design/delProductBomOverview', {
    method: 'POST',
    data: params,
  });
}

export async function exportProductBomOverview(params: any) {
  return request('/api/design/exportProductBomOverview', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function addBomByTemplate(para: any) {
  return request('/api/design/addBomByTemplate', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.file,
    params: {
      batchProductId: para.batchProductId,
    },
  });
}

export async function downloadBomTemplate(para: any) {
  return request('/api/design/downloadBomTemplate', {
    method: 'POST',
    responseType: 'blob',
    data: para,
  });
}

// BOM模板下载
export async function downloadFile(para: any) {
  return request('/api/project/downloadFile', {
    method: 'GET',
    responseType: 'blob',
    data: para,
    params: {
      id: para.id,
    },
  });
}

// bom变更
export async function change(para: any) {
  return request('/api/design/change', {
    method: 'POST',
    params: {
      ids: para.ids,
      nums: para.nums,
    },
  });
}

//BOM物料变更
export async function addBomReview(params: any){
  return request('/api/design/addBomReview',{
    method: 'POST',
    data: params,
  })
}

//BOM提交审批
export async function postBomReviewByIds (para: any){
  return request('/api/design/postBomReviewByIds',{
    method: 'POST',
    params:{
      ids: para.ids,
      withoutPostIds: para.withoutPostIds,
    }
  });
}

// 获取最大版本
export async function getMax(para: any) {
  return request('/api/design/getMax', {
    method: 'POST',
    params: {
      productCode: para.productCode,
    },
  });
}

//获取全部版本
export async function getAllVersion(para: any){
  return request('/api/design/getAllVersion',{
    method: 'POST',
    params:{
      productCode: para.productCode,
    }
  });
}

// BOM模板下载（标准柜体新）
export async function downloadStandardBom(para: any) {
  return request('/api/design/downloadStandardBom', {
    method: 'GET',
    responseType: 'blob',
    data: para,
  });
}

export default {
  getProductBomOverviewByPage,
  addProductBomOverview,
  updateProductBomOverview,
  delProductBomOverview,
  exportProductBomOverview,
};
